<?php

require '../conf.php';

class Books extends FormWriter {

  protected $db = array(
    '.name' => 'FW_books',
    '.user' => USER,
    '.pw'   => PW,
    'book' => array(
      'isbn' => array(
        'type'    => 'str',
        'minlen'  => 16,
        'maxlen'  => 16,
        'size'    => 16
      ),
      'title' => array(
        'type'   => 'str',
        'null'   => FALSE,
        'maxlen' => 100,
        'size'   => 50
      ),
      '.key' => 'isbn'
    ),
    'writer' => array(
      'id' => array(
        'type'    => 'int',
        'minval'  => 0,
        'autoinc' => TRUE
      ),
      'name' => array(
        'type'   => 'str',
        'null'   => FALSE,
        'maxlen' => 50,
        'size'   => 50,
        'label'  => 'writer'
      ),
      '.key' => 'id'
    ),
    'author' => array(
      'book'   => 'book.isbn',
      'writer' => 'writer.id',
      '.key'   => array(
        array(
          'type' => 'primary',
          'cols' => 'book, writer'
        ),
        array(
          'type'  => 'foreign',
          'cols'  => 'book',
          'table' => 'book',
          'refs'  => 'isbn'
        ),
        array(
          'type'  => 'foreign',
          'cols'  => 'writer',
          'table' => 'writer',
          'refs'  => 'id'
        )
      )
    )
  );
}

# End of file
# vim: set ts=2 sw=2 et:
?>
